<template>
<div>
  <div v-for="(item,index) in shopp" :key="index"> 
    <!-- <van-card   
  :num="item.count"
  price="2.00"
  :desc="item.id"  
  :title="item.text"
  :thumb="item.src"
/>
 <div slot="tags">
    <van-tag plain type="danger">标签</van-tag>
    <van-tag plain type="danger">标签</van-tag>
  </div>
  <div slot="footer">
    <van-button size="mini">按钮</van-button>
    <van-button size="mini">按钮</van-button>
  </div>
   </van-card> -->
   <van-card
    :num="item.count"
    :price="item.number*item.count"
  :title="item.text"
  :thumb="item.src"
>
  <div slot="tags">
    <van-tag plain type="danger">标签</van-tag>
    <van-tag plain type="danger">标签</van-tag>
  </div>
  <div slot="footer">
    <van-button size="mini"  @click="buttonlink(index)">-</van-button>
    <van-button size="mini"  @click="buttonlist(index)">+</van-button>
  </div>
</van-card>
<van-submit-bar
  :price="zong"
  button-text="提交订单"  
  @submit="onSubmit"
 />
  </div>
</div>
</template>

<script>
import qu from "@/plugins/quchong.js";
export default {
  data(){
      return{
           shopp:[],
           zong:0
      }
            
  },
  counted(){
    zong()
  },
  mounted() {
    var  wo=qu(this.$store.state.data)
              console.log(wo)
              this.shopp=wo;

  },
  methods:{
     buttonlink(index){
      this.shopp[index].count<= 0 ?  this.shopp[index].count = 0 :   this.shopp[index].count--;
      var  aunmun=0;
   for(var  i=0; i< this.shopp.length; i++){
        aunmun+=this.shopp[index].count*this.shopp[index].number
       console.log(aunmun);
   }
   this.zong=aunmun
     },
     buttonlist(index){
this.shopp[index].count++;
var  aunmun=0;
   for(var  i=0; i< this.shopp.length; i++){
        aunmun+=this.shopp[index].count*this.shopp[index].number
       console.log(aunmun);
   }
   this.zong=aunmun
     },
     onSubmit(){
         console.log(123456)
         alert("你好，你一共需要支付"+this.zong+"元,确认支付吗")
     }

//      zong(){
// var  aunmun=0;
//    for(var  i=0; i< this.shopp.length; i++){
//         aunmun+=this.shopp[index].count*this.shopp[index].number
//        console.log(aunmun);
//    }
//    this.zong=aunmun

//      }
     
  }
};
</script>

<style>
</style>
